package tjs.study.notes.alibaba.user.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import tjs.study.notes.alibaba.user.rpc.OrderRPC;

/**
 * Created by Nicky.Tang on 2022/1/2 4:20 下午
 *
 * @since 02.12.10
 */
@Service
public class UserServiceA {
    private static final Logger log = LoggerFactory.getLogger(UserServiceA.class);

    @Autowired
    private OrderRPC orderRPC;

    @Autowired
    private Environment environment;

    public String buy(String userId) {
        log.info("当前进程：{}", environment.getProperty("server.port"));
        log.info("1. 获取用户信息 userid:{}", userId);
        String resOrder = orderRPC.newOrder(userId);
        log.info("2. 订单生成完成 orderId:{}", resOrder);
        return environment.getProperty("server.port") + ":" + resOrder;
    }
}
